package net.lab1024.sa.admin.module.business.address.controller;

import net.lab1024.sa.admin.module.business.address.domain.form.AddressAddForm;
import net.lab1024.sa.admin.module.business.address.domain.form.AddressQueryForm;
import net.lab1024.sa.admin.module.business.address.domain.form.AddressUpdateForm;
import net.lab1024.sa.admin.module.business.address.domain.vo.AddressVO;
import net.lab1024.sa.admin.module.business.address.service.AddressService;
import net.lab1024.sa.admin.module.business.picture.domain.form.PictureAddForm;
import net.lab1024.sa.admin.module.business.picture.domain.vo.PictureVO;
import net.lab1024.sa.base.common.domain.ValidateList;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import net.lab1024.sa.base.common.domain.ResponseDTO;
import net.lab1024.sa.base.common.domain.PageResult;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import cn.dev33.satoken.annotation.SaCheckPermission;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;

import java.util.List;
import java.util.Map;

/**
 * 全景图地点添加 Controller
 *
 * @Author 骆伟林
 * @Date 2025-10-23 14:52:49
 * @Copyright 软件需求工程第八组
 */

@RestController
@Tag(name = "全景图地点添加")
public class AddressController {

    @Resource
    private AddressService addressService;

    @Operation(summary = "分页查询 @author 骆伟林")
    @PostMapping("/address/queryPage")
    @SaCheckPermission("system:map:search")
    public ResponseDTO<PageResult<AddressVO>> queryPage(@RequestBody @Valid AddressQueryForm queryForm) {
        return ResponseDTO.ok(addressService.queryPage(queryForm));
    }

    @Operation(summary = "添加 @author 骆伟林")
    @PostMapping("/address/add")
    @SaCheckPermission("address:add")
    public ResponseDTO<Map<String, Object>> add(@RequestBody @Valid AddressAddForm addForm) {
        return addressService.add(addForm);
    }
    @Operation(summary = "批量新增 @author 骆伟林")
    @PostMapping("/address/batchAdd")
    @SaCheckPermission("address:add")
    public ResponseDTO<List<Map<String, Object>>> batchAdd(@RequestBody @Valid ValidateList<AddressAddForm> addFormList) {
        return addressService.batchAdd(addFormList);
    }


    @Operation(summary = "更新 @author 骆伟林")
    @PostMapping("/address/update")
    @SaCheckPermission("address:update")
    public ResponseDTO<String> update(@RequestBody @Valid AddressUpdateForm updateForm) {
        return addressService.update(updateForm);
    }

    @Operation(summary = "批量删除 @author 骆伟林")
    @PostMapping("/address/batchDelete")
    @SaCheckPermission("address:delete")
    public ResponseDTO<String> batchDelete(@RequestBody ValidateList<Long> idList) {
        return addressService.batchDelete(idList);
    }

    @Operation(summary = "单个删除 @author 骆伟林")
    @GetMapping("/address/delete/{addressId}")
    @SaCheckPermission("address:delete")
    public ResponseDTO<String> batchDelete(@PathVariable Long addressId) {
        return addressService.delete(addressId);
    }

    @Operation(summary = "获取全景图地点列表 @author 骆伟林")
    @GetMapping("/picture/getAddressList")
    @SaCheckPermission("system:map:search")
    public ResponseDTO<List<AddressVO>> getAddressList() {
        return ResponseDTO.ok(addressService.getAddressList());
    }
}
